package com.nbufe.utils;

import com.nbufe.common.core.utils.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author luzhiheng
 * @date 2024-01-17
 */
public class DateUtil {

    /**
     * 移除月前面的0
     *
     * @param yearMonth
     */
    public static String removeZero(String yearMonth) {
        if (StringUtils.isEmpty(yearMonth)) {
            return "";
        }
        String[] split = yearMonth.split("-");
        int month = Integer.parseInt(split[1]);
        return split[0] + "-" + month;
    }

    /**
     * 格式化MM
     *
     * @param date
     */
    public static String formatMM(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("MM");
        String format = sdf.format(date);
        return format;
    }
}


